import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class DemoLocalizationsDelegate
    extends LocalizationsDelegate<DemoLocalizations> {
  const DemoLocalizationsDelegate();

  @override
  bool isSupported(Locale locale) =>
      DemoLocalizations.languages().contains(locale.languageCode);

  @override
  Future<DemoLocalizations> load(Locale locale) {
    // Returning a SynchronousFuture here because an async "load" operation
    // isn't needed to produce an instance of DemoLocalizations.
    return SynchronousFuture<DemoLocalizations>(DemoLocalizations(locale));
  }

  @override
  bool shouldReload(DemoLocalizationsDelegate old) => false;
}

class DemoLocalizations {
  DemoLocalizations(this.locale);

  final Locale locale;

  static DemoLocalizations of(BuildContext context) {
    return Localizations.of<DemoLocalizations>(context, DemoLocalizations)!;
  }

  static const _localizedValues = <String, Map<String, String>>{
    'en': {
      'home': 'home',
      'accountHint': "Username",
      'login': 'login',
      'pswHint': "Password",
      'scan': 'scan',
      'Camera is not authorized': 'Camera is not authorized',
      'loginTime': 'loginTime',
      'empty': 'empty',
      'online': 'online',
      'offline': 'offline',
      'no data': 'no data',
      'Query the status of the motherboard':
          'Query the status of the motherboard',
      'Query device information': 'Query device information',
      'Fan debugging': 'Fan debugging',
      'Equipment debugging': 'Equipment debugging',
      'search': 'search',
      'help': 'help',
      'Read parameter value': 'Read parameter value',
      'g1': 'G1',
      'g2': 'G2',
      'g3': 'G3',
      'g4': 'G4',
      'g5': 'G5',
      'g6': 'G6',
      'g7': 'G7',
      'g8': 'G8',
      'g9': 'G9',
      'g10': 'G10',
      'g11': 'G11',
      'g12': 'G12',
      'g13': 'G13',
      'g14': 'G14',
      'Gate left': 'Gate left'
    },
    'zh': {
      'home': '主页',
      'accountHint': "请输入账号",
      'login': "登录",
      'pswHint': '请输入密码',
      'scan': '扫一扫',
      'Camera is not authorized': '相机未授权',
      'loginTime': '登录时间',
      'empty': '空空如也',
      'online': '在线',
      'offline': '离线',
      'no data': '没有数据',
      'Query the status of the motherboard': '查询主板状态',
      'Query device information': '查询设备信息',
      'Fan debugging': '风扇调试',
      'Equipment debugging': '设备调试',
      'search': '搜索',
      'help': '帮助',
      'Read parameter value': '读取参数值',
      'g1': 'G1',
      'g2': 'G2',
      'g3': 'G3',
      'g4': 'G4',
      'g5': 'G5',
      'g6': 'G6',
      'g7': 'G7',
      'g8': 'G8',
      'g9': 'G9',
      'g10': 'G10',
      'g11': 'G11',
      'g12': 'G12',
      'g13': 'G13',
      'g14': 'G14',
      'Gate left': '左开闸',
    },
  };

  static List<String> languages() => _localizedValues.keys.toList();

  String get title {
    return _localizedValues[locale.languageCode]!['title']!;
  }

  String get home {
    return _localizedValues[locale.languageCode]!["home"]!;
  }

  String get accountHint =>
      _localizedValues[locale.languageCode]!['accountHint']!;

  String get login => _localizedValues[locale.languageCode]!['login']!;

  String get pswHint => _localizedValues[locale.languageCode]!['pswHint']!;

  String get scan => _localizedValues[locale.languageCode]!['scan']!;

  String get cameraNotAuthorized =>
      _localizedValues[locale.languageCode]!['Camera is not authorized']!;

  String get loginTime => _localizedValues[locale.languageCode]!['loginTime']!;

  String get empty => _localizedValues[locale.languageCode]!['empty']!;

  String get online => _localizedValues[locale.languageCode]!['online']!;

  String get offline => _localizedValues[locale.languageCode]!['offline']!;

  String get noData => _localizedValues[locale.languageCode]!['no data']!;

  String get queryTheStatusOfTheMotherboard => _localizedValues[
      locale.languageCode]!['Query the status of the motherboard']!;

  ///查询设备信息
  String get queryDeviceInformation =>
      _localizedValues[locale.languageCode]!['Query device information']!;

  String get fanDebugging =>
      _localizedValues[locale.languageCode]!['Fan debugging']!;

  String get equipmentDebugging =>
      _localizedValues[locale.languageCode]!['Equipment debugging']!;

  String get search => _localizedValues[locale.languageCode]!['search']!;

  String get help => _localizedValues[locale.languageCode]!['help']!;

  String get readParameterValue =>
      _localizedValues[locale.languageCode]!['Read parameter value']!;

  String get g1 => _localizedValues[locale.languageCode]!['g1']!;

  String get g2 => _localizedValues[locale.languageCode]!['g2']!;

  String get g3 => _localizedValues[locale.languageCode]!['g3']!;

  String get g4 => _localizedValues[locale.languageCode]!['g4']!;

  String get g5 => _localizedValues[locale.languageCode]!['g5']!;

  String get g6 => _localizedValues[locale.languageCode]!['g6']!;

  String get g7 => _localizedValues[locale.languageCode]!['g7']!;

  String get g8 => _localizedValues[locale.languageCode]!['g8']!;

  String get g9 => _localizedValues[locale.languageCode]!['g9']!;

  String get g10 => _localizedValues[locale.languageCode]!['g10']!;

  String get g11 => _localizedValues[locale.languageCode]!['g11']!;

  String get g12 => _localizedValues[locale.languageCode]!['g12']!;

  String get g13 => _localizedValues[locale.languageCode]!['g13']!;

  String get g14 => _localizedValues[locale.languageCode]!['g14']!;

  String get gateLeft => _localizedValues[locale.languageCode]!['Gate left']!;
}
